#include "widget.h"
#include "ui_widget.h"
#include <QHBoxLayout>
#include <QPushButton>
#include <QVBoxLayout>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QPushButton* button1 = new QPushButton("按钮1");
    QPushButton* button2 = new QPushButton("按钮2");
    QPushButton* button3 = new QPushButton("按钮3");
    QPushButton* button4 = new QPushButton("按钮4");
    QPushButton* button5 = new QPushButton("按钮5");

    QHBoxLayout* layout = new QHBoxLayout;
    QVBoxLayout* layout2 = new QVBoxLayout;

    // 做了父子对象的管理
    layout->addWidget(button1);
    layout->addWidget(button2);
    layout->addWidget(button3);

    layout2->addWidget(button4);
    layout2->addWidget(button5);

    this->setLayout(layout);
    // 水平布局管理器中添加垂直布局管理器
    layout->addLayout(layout2);
}

Widget::~Widget()
{
    delete ui;
}

